*Replication syntax to: 
*Mader & Schoen, 2014. Chancellor Merkel, the European debt crisis and the AfD: An analysis of voting behaviour in the 2013 Federal Election.

*This syntax prepares data for export to Mplus.

*Ppen GLES "Langfrist-Online-Tracking" T21: 
use "...ZA5721_v1-0-0.dta", clear
set more off, permanently
*note. Data can be retrieved from GESIS: http://www.gesis.org/en/elections-home/gles/data-and-documents/
*	   Reference:
*	   Rattinger, Hans; Ro�teutscher, Sigrid; Schmitt-Beck, R�diger; We�els, Bernhard; Wolf, Christof (2013):
*	   Langfrist-Online-Tracking T21 (GLES). GESIS Datenarchiv, K�ln. ZA5721 Datenfile Version 1.0.0


*DV: indended vote choice, nominal
	tab1 t903ba t903bb, nolabel mis

	gen votechoi = t903ba
	mvdecode votechoi, mv(-98 = .a \ -99 = .b \ -97 = .c \ -83 = .d \ 801=.e)
	recode votechoi (1 = 1) (4 = 7) (5 = 2) (6 = 3) (7 = 4) (215 = 5) (322 = 6)
	label variable votechoi "vote choice: second vote"
	label define votechoice2_lb 1 "CDU/CSU" 2 "FDP" 3 "GRUENE" 4 "DIE LINKE" 5 "PIRATEN" 6 "AfD" 7 "SPD" 
	label val votechoi votechoice2_lb

	tab1 votechoi

*intended vote choice, dummies
	gen v_union = 0
	replace v_union = 1 if votechoi == 1

	gen v_fdp = 0
	replace v_fdp = 1 if votechoi == 2

	gen v_spd = 0
	replace v_spd = 1 if votechoi == 7

	gen v_gruen = 0
	replace v_gruen = 1 if votechoi == 3

	gen v_linke = 0
	replace v_linke = 1 if votechoi == 4

	gen v_pirat = 0
	replace v_pirat = 1 if votechoi == 5

	gen v_afd = 0
	replace v_afd = 1 if votechoi == 6

	tab1 v_union v_fdp v_spd v_gruen v_linke v_pirat v_afd




*IV: predispositions

	* economic liberalism
	recode t308c (1 = 0) (2 = .25) (3 = .5) (4 = .75) (5 = 1), gen(el1) 
	recode t308d (1 = 1) (2 = .75) (3 = .5) (4 = .25) (5 = 0), gen(el2)
	recode t308i (1 = 1) (2 = .75) (3 = .5) (4 = .25) (5 = 0), gen(el3)

	tab1 t114

	mvdecode t114, mv(-98 = .a \ -99 = .b \ -97 = .c \ -83 = .d)
	recode t114 (1 = 11) (2 = 10) (3 = 9) (4 = 8) (5 = 7) (6 = 6) (7 = 5) (8 = 4) (9 = 3) (10 = 2) (11 = 1) , gen(t114_r)
	gen el4 = (t114_r - 1)/10

	label variable el4 "socioeconomic dimension"
	label define socioeconomic_dimension_lb 0 "more welfare programs"  1 "less taxes and public spending" 
	label val el4 socioeconomic_dimension_lb

	tab1 el4

	egen el_ind = rowmean(el2 el3 el4)


	*ethnocentrism
	recode t308a (1 = 0) (2 = .25) (3 = .5) (4 = .75) (5 = 1), gen(eth1) 

	recode t308j (1 = 0) (2 = .25) (3 = .5) (4 = .75) (5 = 1), gen(eth3) 

	tab1 t154

	mvdecode t154, mv(-98 = .a \ -99 = .b \ -97 = .c \ -83 = .d)
	gen eth4 = (t154 - 1)/10

	label variable eth4 "libertarian authoritarian dimension"
	label define lib_auth_dimension_lb 0 "more immigration" 1 "less immigration"
	label val eth4 lib_auth_dimension_lb

	tab1 eth4

	egen eth_ind = rowmean(eth1 eth4)


	*moral traditionalism
	recode t308h (1 = 1) (2 = .75) (3 = .5) (4 = .25) (5 = 0), gen(mt1) 
	recode t308k (1 = 0) (2 = .25) (3 = .5) (4 = .75) (5 = 1), gen(mt2)

	egen mt_ind = rowmean(mt1 mt2)

	*environmental concern
	tab1 t308g
	recode t308g (1 = 1) (2 = .75) (3 = .5) (4 = .25) (5 = 0), gen(ec1) 
	
	
	tab1 t318
	*value labels in GLES data wrong
	
	mvdecode t318, mv(-98 = .a \ -99 = .b \ -97 = .c \ -83 = .d)
	recode t318 (1 = 11) (2 = 10) (3 = 9) (4 = 8) (5 = 7) (6 = 6) (7 = 5) (8 = 4) (9 = 3) (10 = 2) (11 = 1) , gen(t318_r)

	gen ec2 = (t318_r - 1)/10

	label variable ec2 "climate change"
	label define climate_change_lb 0 "economic growth more important than climate" 1 "climate more important than economic growth"
	label val ec2 climate_change_lb

	tab1 ec2

	egen ec_ind = rowmean(ec1 ec2)


	*auxiliary
	recode t308b (1 = 1) (2 = .75) (3 = .5) (4 = .25) (5 = 0), gen(v1) 
	recode t308f (1 = 0) (2 = .25) (3 = .5) (4 = .75) (5 = 1), gen(v2)


*party identifiactions
	tab1 t46a
	tab1 t46a, nolabel mis
	
	*for desciptives
	gen t46a_r = t46a
	recode t46a_r (2 = 1) (3 = 1) (4 = 2) (5 = 4) (6 = 3)(7 = 4) (215 = 4) (322 = 4) (801 = 4) (808 = 5)
	label variable t46a_r "Party identification"
	label define t46a_r_lb 1 "CDU/CSU" 2 "GRUENE" 3 "SPD" 4 "other party" 5 "no party" , replace
	label val t46a_r t46a_r_lb
	tab1 t46a_r
	
	*	mvdecode t46a_r, mv(-98 = .a \ -99 = .b \ -97 = .c \ -83 = .d \ )
	
	*dummies
	gen union_d = 0
	replace union_d = 1 if t46a == 2 | t46a == 3

	gen spd_d = 0
	replace spd_d = 1 if t46a == 4

	gen fdp_d = 0
	replace fdp_d = 1 if t46a == 5

	gen gruen_d = 0
	replace gruen_d = 1 if t46a == 6

	gen linke_d = 0
	replace linke_d = 1 if t46a == 7

	gen pira_d = 0
	replace pira_d = 1 if t46a == 215

	gen afd_d = 0
	replace afd_d = 1 if t46a == 322

	gen no_pi = 0
	replace no_pi = 1 if t46a == 808

	*indices
	tab1 t47
	tab1 t47, nolabel

	recode t47 (1 = 5) (2 = 4) (3 = 3) (2 = 4) (1 = 5), gen(t47_r)

	gen union = 0
	replace union = t47_r if t46a == 2 | t46a == 3

	gen spd = 0
	replace spd = t47_r if t46a == 4

	gen fdp = 0
	replace fdp = t47_r if t46a == 5

	gen gruen = 0
	replace gruen = t47_r if t46a == 6

	gen linke = 0
	replace linke = t47_r if t46a == 7

	gen pira = 0
	replace pira = t47_r if t46a == 215

	gen afd = 0
	replace afd = t47_r if t46a == 322

	foreach var of varlist union spd fdp gruen linke pira afd {
	gen `var'_i = (`var' - 1)/5
	}


*ideology
	tab1 t24

	gen lire = (t24 -1) / 10

	
	
*issue preference: debt crisis
	recode t308e (1 = 1) (2 = .75) (3 = .5) (4 = .25) (5 = 0), gen(euro)

	
	
	mvdecode eth1 euro eth3 eth4 mt1 mt2 el1 el2 el3 el4 ec1 ec2 v1 v2, mv(-98 = .a \ -99 = .b \ -97 = .c \ -83 = .d)
	label define agree_disagree_lb 0 "completely disagree" 1 "completely agree"
	label val eth1 euro eth3 eth4 mt1 mt2 el1 el2 el3 el4 ec1 ec2 v1 v2 agree_disagree_lb


*candidate preferences
	tab1 t925
	tab1 t925, nolabel mis
	
	svyset [iweight = wei_mzz]
	svy:  proportion t925
	

	gen cpmerk = 0
	replace cpmerk = 1 if t925 == 1
		
	gen cpstein = 0
	replace cpstein = 1 if t925 == 2

	*candidate evaluation
	tab1 t15a t15b t15c t15d t15e

	gen merkel = (t15a - 1 ) / 10
	gen stein = (t15b - 1 ) / 10
	gen tritt = (t15c - 1 ) / 10
	gen gysi = (t15d - 1 ) / 10
	gen brue = (t15e - 1 ) / 10

	

	
	
*additional variables

	**satisfaction with goverment 
	tab1 t16

	gen sat = (t16 - 1) / 10 
	tab sat


	**satisfaction with government handling the debt crisis
	tab1 t315a

	recode t315a (1 = 1) (2 = .75) (3 = .5) (4 = .25) (5 = 0), gen(gov_sat) 

	**satisfaction with Merkel handling the debt crisis
	tab1 t315b

	recode t315b (1 = 1) (2 = .75) (3 = .5) (4 = .25) (5 = 0), gen(merk_sat) 


	**resposnsibility debt crisis
	tab1 t314

	gen finance = 0
	replace finance = 1 if t314 == 1 | t314 == 2

	gen indebted = 0
	replace indebted = 1 if t314 == 8



	*politcal interest
	tab1 t5 t924 t921

	recode t5 (1 = 1) (2 = 0.75) (3 = 0.5) (4 = 0.25) (5 = 0), gen(inv1)
	recode t924 (1 = 1) (2 = 0.75) (3 = 0.5) (4 = 0.25) (5 = 0), gen(inv2)
	recode t921 (1 = 1) (2 = 0.75) (3 = 0.5) (4 = 0.25) (5 = 0), gen(inv3)

	*age
	tab1 t2

	gen alter = (2013 - t2)

	*education
	tab1 t3
	tab1 t3, nolabel

	gen eduhi = 0
	replace eduhi = 1 if t3 == 8 | t3 == 7

	gen edulo= 0
	replace edulo = 1 if t3 == 1 | t3 == 2 | t3 == 3 | t3 == 4

	*gender
	tab1 t1
	tab1 t1, nolabel

	recode t1 (1 = 0) (2 = 1), gen(female)

	*region
	tab1 ostwest
	tab1 ostwest, nolabel

	recode ostwest (1 = 1) (2 = 0), gen(ost)
	

		
	
	
*Descriptives Table 1*****************************************************************************************************************************
	svyset _n [pweight=wei_mzz], vce(linearized) singleunit(missing)

	
	svy: tab t46a_r

	svy: tab t925
	svy: tab t925 if t46a_r == 1
	svy: tab t925 if t46a_r == 2
	svy: tab t925 if t46a_r == 3
	svy: tab t925 if t46a_r == 5
	
	svy: tab euro
	svy: tab euro if union_d == 1
	svy: tab euro if spd_d == 1
	svy: tab euro if gruen_d == 1
	svy: tab euro if no_pi == 1
	

	
	
	
*stata2mplus*****************************************************************************************************************************
stata2mplus lfdn /// id
	wei_mzz /// soz.de. weight
	votechoi v_union v_fdp v_spd v_gruen v_linke v_pirat v_afd /// 
	eth1 euro eth3 eth4 mt1 mt2 el1 el2 el3 el4 ec1 ec2 v1 v2 /// 
	el_ind eth_ind mt_ind ec_ind  ///  
	union_d spd_d fdp_d gruen_d linke_d pira_d afd_d no_pi t46a_r t46a ///
	union_i spd_i fdp_i gruen_i linke_i pira_i afd_i ///  
	merkel stein tritt gysi brue t925 cpmerk cpstein /// 
	sat ///
	finance indebted gov_sat merk_sat ///
	lire ///
	inv1 inv2 inv3 ///
	alter eduhi edulo female ost ///
	t156a t156b t156c t156f ///
	using DATA_btw13, replace

